﻿// 禁用刷新功能
try { document.oncontextmenu = function () { return (document.selection.createRange().text != '' || document.activeElement.className == 'TextBoxCss'); }; } catch (e) { }
try { document.onkeydown = function () { if ((event.keyCode == 8 && event.srcElement.type != 'text' && event.srcElement.type != 'textarea' && event.srcElement.type != 'password') || (event.keyCode == 8 && event.srcElement.readOnly == true) || (event.keyCode == 13 && event.srcElement.tagName != 'INPUT' && event.srcElement.tagName != 'TEXTAREA') || event.keyCode == 116 || event.keyCode == 121 || event.keyCode == 122 || (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 82)) || (event.altKey && (event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 38 || event.keyCode == 40))) { event.keyCode = 0; event.returnValue = false; } else if (event.keyCode == 13 && (event.srcElement.type == 'text' || event.srcElement.type == 'textarea' || event.srcElement.type == 'password')) { event.keyCode = 9; } }; } catch (e) { }
try { window.history.forward(); } catch (e) { }
try { document.onselectstart = function () { return (event.srcElement.type == 'text' || event.srcElement.type == 'textarea' || event.srcElement.type == 'password'); }; } catch (e) { }
// 标题栏及状态栏默认文本
try { if (self.opener != null) { document.title = self.opener.top.document.title; window.defaultStatus = self.opener.top.defaultStatus; } else if (self != top) { document.title = top.document.title; window.defaultStatus = top.defaultStatus; } } catch (e) { }
// 取消超链接焦点
try { document.onmouseup = function () { if (event.srcElement.tagName == "A") { event.srcElement.blur(); } }; } catch (e) { }
// 字符串去空格函数
String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
// 字符串判断是否为数字
String.prototype.isnumeric = function () {
    return StringRegExp(this.trim(), "^\\-?\\d+(\\.\\d+)?$");
}
// 字符串替换函数
function replace(s, s1, s2) {
    if (s != s.replace(s1, s2)) {
        return replace(s.replace(s1, s2), s1, s2)
    }
    else {
        return s;
    }
}
// 正则表达式验证
function StringRegExp(sStr, sReg) {
    var reg = new RegExp(sReg);
    return reg.test(sStr);
}
// 获取文件名称
function GetFileName(sPath) {
    sPath = sPath.substr(sPath.lastIndexOf("\\") + 1);
    if (sPath.lastIndexOf(".") > 0) {
        sPath = sPath.substr(0, sPath.lastIndexOf("."));
    }
    return sPath;
}
// UrlConvert函数
function UrlConvert(sUrl) {
    if (sUrl.indexOf("http://") >= 0) {
        sUrl = replace(sUrl, sUrl.substring(sUrl.indexOf("http://"), sUrl.indexOf("/", sUrl.indexOf("http://") + 7)), "");
    }
    var wz = sUrl.indexOf(".aspx?", sUrl.indexOf(".aspx?") + 6);
    if (wz > 0) {
        sUrl = sUrl.substr(0, wz) + replace(sUrl.substr(wz), "&", "%26");
    }
    return sUrl;
}
// 勾选或取消勾选全部
function SelectCheckAll(tCheckBox) {
    try {
        var tThis = tCheckBox;
        var tTable = null;
        while (tThis != null) {
            if (tThis.nodeName == "TABLE") {
                tTable = tThis;
                break;
            }
            tThis = tThis.parentNode;
        }
        if (tTable != null) {
            var bChecked = tCheckBox.checked;
            var tCheckBoxs = tTable.getElementsByTagName("INPUT");
            for (i = 0; i < tCheckBoxs.length; i++) {
                if (tCheckBoxs[i].type == "checkbox") {
                    tCheckBoxs[i].checked = bChecked;
                }
            }
        }
    }
    catch (e) { }
}
// 设置选中颜色
function SelColor(tThis) {
    try {
        if (tThis == null) {
            tThis = event.srcElement;
        }
        var tRow = null;
        var tTable = null;
        while (tThis != null) {
            if (tThis.nodeName == "TR") {
                tRow = tThis;
            }
            else if (tThis.nodeName == "TABLE") {
                tTable = tThis;
                break;
            }
            tThis = tThis.parentNode;
        }
        if (tTable != null) {
            var tRows = tTable.getElementsByTagName("tr");
            for (i = 0; i < tRows.length; i++) {
                tRows[i].style.backgroundColor = (tRows[i] == tRow ? "#9DD9DA" : (i % 2 == 0 ? "#E7F3FF" : ""));
                var tCheckBoxs = tRows[i].getElementsByTagName("INPUT");
                if (tCheckBoxs.length > 0 && tCheckBoxs[0].type == "checkbox" && tCheckBoxs[0].checked) {
                    tRows[i].style.color = "#FF0000";
                }
                else {
                    tRows[i].style.color = "";
                }
            }
        }
    }
    catch (e) { }
}
// 打开模式窗体
function ShowDialog(sUrl, iWidth, iHeight) {
    window.modalDialogWidth = iWidth;
    window.modalDialogHeight = iHeight;
    return showModalDialog(UrlConvert("PdmDialog.aspx?DialogUrl=" + sUrl), window, "dialogWidth=" + iWidth + "px;dialogHeight=" + iHeight + "px;help=no;scrollbar=no;status=no;resizable=no");
}
// 打开普通窗体
function ShowWindow(sUrl, iWidth, iHeight) {
    var oWindow = window.open(sUrl, "_blank", "location=no,menubar=yes,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=" + iWidth + ",height=" + iHeight, true);
    oWindow.focus();
}
